package hot100;

public class lengthOfLongestSubstring {
    public int lengthOfLongestSubstring(String s) {
        int[] hash = new int[127];
        int left = 0;
        int right = 0;
        int max = 0;
        while (right < s.length()) {
            hash[s.charAt(right)]++;
            while (hash[s.charAt(right)] > 1) {

                hash[s.charAt(left)]--;
                left++;
            }
            right++;
            max = Math.max(right - left,max);
        }
        return max;
    }
}
